package com.kawa.remote;

import com.kawa.fallback.UserRemoteFallBack;
import com.kawa.pojo.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 当服务调用正常 就会根据接口生成实例进行服务正常调用
 *  但是如果调用的服务不正常，则启用备选方案，调用回调实现类进行服务降级
 */
@FeignClient(name = "eureka-client-provider",fallback = UserRemoteFallBack.class)
public interface UserRemote {

    @GetMapping("/user/get/{id}")
    public String getUserById(@PathVariable Long id);

    @RequestMapping("/user/add")
    public User addUser(@RequestBody User user);

}
